package cn.snowheart.iterator.iterator;

import java.util.Iterator;

/**
 * 数组迭代器
 *
 * @author liuwanxiang
 * @version 2019/07/09
 */
public class ArrayIterator<T> implements Iterator<T> {

    /**
     * 菜单数组
     */
    private T[] array;
    /**
     * 下标指针位置
     */
    int pos = 0;

    public ArrayIterator(T[] array) {
        this.array = array;
    }

    @Override
    public boolean hasNext() {
        if (pos >= array.length || array[pos] == null) {
            return false;
        }
        return true;
    }

    @Override
    public T next() {
        return array[pos++];
    }
}
